//
//  DrawView.m
//  04-06-绘制文字和图片
//
//  Created by student on 16/4/6.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "DrawView.h"

@implementation DrawView


-(void)setSelImage:(UIImage *)selImage
{
    _selImage = selImage;
    [self setNeedsDisplay];
}

-(void)drawRect:(CGRect)rect
{
    //2. 绘制文字
    NSString *str=@"qwertd";
    //字符串格式字典
    NSMutableDictionary *textDict=[NSMutableDictionary dictionary];
    textDict[NSFontAttributeName] = [UIFont systemFontOfSize:15];//字体大小
    textDict[NSForegroundColorAttributeName] = [UIColor greenColor];//颜色
    
    
    //带格式的字符串
    NSAttributedString *aStr=[[NSAttributedString alloc]initWithString:@"Hello!" attributes:textDict];
    
    [str drawAtPoint:CGPointZero withAttributes:textDict];
    [aStr drawAtPoint:CGPointMake(100, 50)];
    
    //1.绘制图片
    //bundle中的图片
    UIImage *img=[UIImage imageNamed:@"langmuwine"];
    [img drawAtPoint:CGPointZero];
    [img drawInRect:CGRectMake(50, 50, 29, 45)];
    [img drawInRect:rect];
    //外部传入的图片
    [self.selImage drawInRect:rect];
    
   
}
@end
